package com.heima.article.controller.v1;

import com.heima.article.service.ApArticleService;
import com.heima.model.article.dto.ArticleHomeDTO;
import com.heima.model.common.constants.user.ArticleConstants;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "app首页文章展示",tags = "app首页文章展示")
@RestController
@RequestMapping("/api/v1/article")
public class ArticleHomeController {
    @Autowired
    private ApArticleService apArticleService;

    @PostMapping("/load")
    public ResponseResult load(ArticleHomeDTO dto){
       // return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,dto);
        return apArticleService.loadFromCache(ArticleConstants.LOADTYPE_LOAD_MORE,dto);
    }
    @PostMapping("/loadmore")
    public ResponseResult loadmore(ArticleHomeDTO dto){
        return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_MORE,dto);
    }
    @PostMapping("/loadnew")
    public ResponseResult loadnew(ArticleHomeDTO dto){
        return apArticleService.load(ArticleConstants.LOADTYPE_LOAD_NEW,dto);
    }

}